//
//  SAFeedbackViewController.m
//  SunOn
//
//  Created by RazeenCheng on 2017/5/2.
//  Copyright © 2017年 NeoZhang. All rights reserved.
//  最新咨询界面

#import "SAFeedbackViewController.h"
#import "SAFeedBackHeadTableViewCell.h"
#import "SAFeedBackTableViewCell.h"
#import "SAInformationFeedbackViewController.h"
#import "SAFeedBackDetaileViewController.h"
#import "SAFeedbackQuestionListViewController.h"
#import "SAFeedbackConsultingViewController.h"
#import "SAFeedBackConsoultDetaileController.h"
#import "SAFeedbackCommonProblemsViewController.h"
#import "SAFeedbackProductConsoultViewController.h"
#import "SAFeedbackHotConsoultViewController.h"
#import "SAFeedbackActiveRankingController.h"
#import "SACollectionNoticeViewController.h"
@interface SAFeedbackViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *tabview;

@end

@implementation SAFeedbackViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"圣奥研发中心";
    self.navigationController.title = @"咨询反馈";
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.tabview];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    UIButton *messageInformation = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [messageInformation setBackgroundImage:SAImageNamed(@"NaviBar-xiaoxi1") forState:(UIControlStateNormal)];
    messageInformation.frame = CGRectMake(0, 0, 25, 25);
    [messageInformation addTarget:self action:@selector(moreMessageInformation:) forControlEvents:(UIControlEventTouchUpInside)];
    UIBarButtonItem *rightitem = [[UIBarButtonItem alloc] initWithCustomView:messageInformation];
    self.navigationItem.rightBarButtonItem = rightitem;
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#0d88e8"]}];
}
#pragma mark - custom method
//更多消息
- (void)moreMessageInformation:(UIButton *)sender {
    [sender setBackgroundImage:SAImageNamed(@"NaviBar-xiaoxi2") forState:(UIControlStateNormal)];
    UIStoryboard *story = [UIStoryboard storyboardWithName:@"Collection" bundle:nil];
    SACollectionNoticeViewController *MessageDetaileVC = [story instantiateViewControllerWithIdentifier:@"SACollectionNoticeViewController"];
    [self.navigationController pushViewController:MessageDetaileVC animated:YES];
}
#pragma mark - view method
//问题反馈
- (IBAction)questionFeedBackAction:(UITapGestureRecognizer *)sender {
    DLog(@"问题反馈");
    UIStoryboard *story = [UIStoryboard storyboardWithName:@"Collection" bundle:nil];
    SAInformationFeedbackViewController *informationVC = [story instantiateViewControllerWithIdentifier:@"SAInformationFeedbackViewController"];
    informationVC.str = @"产品信息";
    [self.navigationController pushViewController:informationVC animated:YES];
}
//常见问题
- (IBAction)commonProblemsAction:(UITapGestureRecognizer *)sender {
    DLog(@"常见问题");
    SAFeedbackCommonProblemsViewController *informationVC = [self.storyboard instantiateViewControllerWithIdentifier:@"SAFeedbackCommonProblemsViewController"];
    informationVC.title = @"常见问题";
    [self.navigationController pushViewController:informationVC animated:YES];
}
//产品咨询
- (IBAction)productConsultingAction:(UITapGestureRecognizer *)sender {
    DLog(@"产品咨询");
    SAFeedbackProductConsoultViewController *informationVC = [self.storyboard instantiateViewControllerWithIdentifier:@"SAFeedbackProductConsoultViewController"];
    [self.navigationController pushViewController:informationVC animated:YES];
}
//最热咨询
- (IBAction)hottestConsultingAction:(UITapGestureRecognizer *)sender {
    DLog(@"最热咨询");
    SAFeedbackHotConsoultViewController *vc = [[SAFeedbackHotConsoultViewController alloc] init];
    vc.hidesBottomBarWhenPushed = YES;
    vc.title = @"最热咨询";
    [self.navigationController pushViewController:vc animated:YES];
}
//活跃度排行
- (IBAction)rankingAction:(UITapGestureRecognizer *)sender {
    DLog(@"活跃度排行");
    SAFeedbackActiveRankingController *vc = [[SAFeedbackActiveRankingController alloc] init];
    vc.hidesBottomBarWhenPushed = YES;
    vc.title = @"活跃度排行";
    [self.navigationController pushViewController:vc animated:YES];
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 1) {
        SAFeedBackTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SAFeedBackTableViewCell" forIndexPath:indexPath];
        [cell configurefeedbackImageHeight:0];
        [cell configurefeedbackPeopleshow:YES];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }else {
        if (indexPath.row == 0) {
            SAFeedBackHeadTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SAFeedBackHeadTableViewCell" forIndexPath:indexPath];
            if (indexPath.section == 0) {
                cell.titleLB.text = @"我的最新反馈";
            }else {
                cell.titleLB.text = @"我的最新咨询";
            }
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell;
        }else {
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
            if (indexPath.section == 0) {
                cell.textLabel.text = @"查看全部问题反馈";
            }else {
                cell.textLabel.text = @"查看全部产品咨询";
            }
            cell.textLabel.font = [UIFont boldSystemFontOfSize:15];
            cell.textLabel.textColor = [UIColor colorWithRed:37/255.0 green:125/255.0 blue:255/255.0 alpha:1.0];
            cell.textLabel.textAlignment = NSTextAlignmentCenter;
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell;
        }
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 1) {
        return 292 - 150;
    }
    return 44;
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 1) {
        if (indexPath.section == 0) {
            //反馈信息详情界面
            SAFeedBackDetaileViewController *feedback = [self.storyboard instantiateViewControllerWithIdentifier:@"SAFeedBackDetaileViewController"];
            feedback.title = @"反馈详情";
            [self.navigationController pushViewController:feedback animated:YES];
        }else {
            SAFeedBackConsoultDetaileController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"SAFeedBackConsoultDetaileController"];
            [self.navigationController pushViewController:vc animated:YES];
        }
    }
    if (indexPath.row == 2) {
        if (indexPath.section == 0) {
            //全部我的反馈信息
            SAFeedbackQuestionListViewController *feedbackQuestion = [[SAFeedbackQuestionListViewController alloc] init];
            feedbackQuestion.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:feedbackQuestion animated:YES];
        }else {
            //全部我的咨询信息
            SAFeedbackConsultingViewController *Consulting = [[SAFeedbackConsultingViewController alloc] init];
            Consulting.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:Consulting animated:YES];
        }
    }
}
#pragma mark - view layout
#pragma mark - setter&getter
- (UITableView *)tabview {
    if (!_tabview) {
        self.tabview = [[UITableView alloc] initWithFrame:CGRectMake(0, 80 + 64, SASCREEN_WIDTH, SASCREEN_HEIGHT) style:(UITableViewStylePlain)];
        self.tabview.delegate = self;
        self.tabview.dataSource = self;
        [self.tabview registerNib:[UINib nibWithNibName:@"SAFeedBackHeadTableViewCell" bundle:nil] forCellReuseIdentifier:@"SAFeedBackHeadTableViewCell"];
        [self.tabview registerNib:[UINib nibWithNibName:@"SAFeedBackTableViewCell" bundle:nil] forCellReuseIdentifier:@"SAFeedBackTableViewCell"];
        [self.tabview registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
        self.tabview.showsVerticalScrollIndicator = NO;
        self.tabview.showsHorizontalScrollIndicator = NO;
        self.tabview.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    return _tabview;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
